package com.hxh.controller;

import com.hxh.entity.output.ApiResult;
import com.hxh.service.ProjectConfigRecordService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * 项目配置记录
 * 提示需要重新生成某个页面等
 */
@RestController
@RequestMapping("/api/projectConfigRecord")
@Slf4j
public class ProjectConfigRecordController {
    @Autowired
    private ProjectConfigRecordService projectConfigRecordService;

    @PostMapping(value = "deleteTips")
    public ApiResult deleteTips(@RequestParam Integer projectId, @RequestParam String type) {
        try {
            switch (type) {
                case "rebootFlag":
                    projectConfigRecordService.clearAllRebootFlag(projectId);
                    break;
                case "initFlag":
                    projectConfigRecordService.clearAllInitFlag(projectId);
                    break;
                case "frontRebuildTable":
                    projectConfigRecordService.clearAllFrontRebuildFlag(projectId);
                    break;
                case "backRebuildTable":
                    projectConfigRecordService.clearAllBackRebuildFlag(projectId);
                    break;
                case "all":
                    projectConfigRecordService.clearAllFlag(projectId);
                    break;
                default:
                    return ApiResult.fail("参数错误！");
            }
            return ApiResult.ok();
        } catch (Exception e) {
            log.error("清除通知异常", e);
            return ApiResult.fail("清除通知异常！");
        }
    }

}
